<template>
  <div class='container'>
    <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="80%"
  >
    <span>
      <el-form ref="form" :model="newform" :rules="rules" label-width="100px">
        <el-form-item label="学科名称" prop="name">
          <el-input v-model="newform.name" />
        </el-form-item>
        <br>
         <el-form-item label="是否显示" prop="show">
         <el-switch
         :active-value="1"
            :inactive-value="0"
           v-model="value2"
   active-color="#13ce66"
  inactive-color="#ff4949">
</el-switch>
        </el-form-item>
      </el-form>
      </span>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="addPeopleList">确 定</el-button>
    </span>
  </el-dialog>
  </div>
</template>

<script>
import { add } from '@/api/hmmm/subjects.js'
export default {
  methods: {
    closeDialog () {
      this.dialogVisible = false
      this.name = ''
      this.$refs.form.resetFields()
    },
    addPeopleList () {
      this.$refs.form.validate(async boo => {
        if (!boo) return
        const { message } = await add(this.form)
        this.$message.success(message)
        this.closeDialog()
        this.getlist()
      })
    }
  }
}
</script>

<style scoped lang='less'></style>
